package com.qd.common.sys.domain.sendmsg;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

@Data
@Accessors(chain = true)
@Slf4j
@ToString
public class MsgContentProperty {
    private String value;
    private String color;

    public MsgContentProperty() {
    }

    public MsgContentProperty(String value) {
        this.value = value;
    }

    public MsgContentProperty(String value, String color) {
        this.value = value;
        this.color = color;
    }

    public void read(JSONObject content) {
        this.value = content.getString("value");
        this.color = content.getString("color");
    }

    public void write(JSONObject content) {
        content.put("value", value);
        content.put("color", color);
    }

    public static void main(String[] args) throws JsonProcessingException {
//        MsgContentProperty msgContentProperty = new MsgContentProperty();
//        ObjectMapper objectMapper = new ObjectMapper();
//        ObjectNode objectNode = objectMapper.createObjectNode();
//        msgContentProperty.setColor("red");
//        msgContentProperty.setValue("1111");
//        msgContentProperty.write(objectNode);
//        System.out.println(objectNode);
//        ObjectNode jsonNode = (ObjectNode)objectMapper.readTree("{\n" +
//                "\t\"color\": \"red\",\n" +
//                "\t\"value\": \"1111\"\n" +
//                "}");
//
//
//       msgContentProperty.read(jsonNode);
//
//        System.out.println(msgContentProperty.getColor()+": "+msgContentProperty.getValue());
    }
}
